package com.kaigejava.juc.toolsdemo.cyclcbarrier;

import java.util.concurrent.TimeUnit;

/**
 * @author kaigejava
 * 不使用cyclicBarrier的
 */
public class NoCyclicBarrierDemo {
    public static void main(String[] args) {
        for(int i = 1;i<=7;i++){
            final  int dragonBall = i;
            new Thread(()->{
                try {
                    //找龙珠会耗费时间，这里每个线程睡2s
                    TimeUnit.SECONDS.sleep(2);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("==当前找到第"+dragonBall+"颗龙珠");
            },""+dragonBall).start();
        }

       new Thread(()->{
           new Dragon().say();
       }).start();
    }

}
